Repository navigation
DEV-1123: take the pressure sensor from SD header byte 224 - #313
Merged
Merged
Conversation
LogAndStream now records the pressure sensor it found at SD header offset 224: bits 0-6 a PRESSURE_SENSOR_ID (the 0xA6 numbering), bit 7 "inferred from the SR number", 0xFE none fitted, 0xFF not recorded. The new SdHeaderPressureSensorId decodes it and gates it on the firmware: LogAndStream on Shimmer3R v1.01.018+ or Shimmer3 v1.01.006+. The gate checks the hardware version because the two version lines overlap; it goes to UtilShimmer directly since ShimmerVerObject.compareVersions(svo, hw, ...) ignores its hardware argument. ShimmerObject.setPressureSensorIdFromSdHeader() records the decoded byte, for ShimmerSDLog to call between setting the board and building the sensor classes. When present it overrides the SR-number rule: - isSupportedBmp581() consults it after DEV-1110's in-band ID (Shimmer3R). - isSupportedBmp280() consults it (Shimmer3), and the Shimmer3 barometer class now follows isSupportedBmp280() rather than the IMU generation, which is the same thing unless the header says otherwise. - An unknown ID, a sensor the platform has no parser path for (BMP180/280 on a Shimmer3R, BMP390/581 on a Shimmer3) or 0xFE leaves the pressure and temperature channels uncalibrated: buildMsg skips calibration when isPressureSensorCalibratable() is false. There is no SR-number fallback; the base sensor class (BMP390 / BMP180) is kept only to name and lay out the channels. A disagreement with the SR-number rule is logged, and an inferred or unknown ID is warned about. isPressureSensorInferred() lets a caller warn too. Like the in-band ID, it is cleared when the board details change. API_00022 covers the decoding and the gate. API_00012-00021 are all taken across branches, hence 22. Choosing the sensor against the SR-number rule is tested end to end through ShimmerSDLog in Shimmer-Advance-API. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Header-state serialization and array-backed calibrated output need correction before approval.
Review effort: Balanced
Findings: 1
Open (2)
What changed in this PR
Builds on DEV-1110 to use SD header byte 224 for pressure-sensor selection instead of relying solely on board revisions.
Changes:
- Adds hardware-aware header decoding and firmware gates.
- Applies sensor overrides and skips calibration for unsupported or unfitted sensors.
- Adds decoding and version-boundary tests.
| File | Description |
|---|---|
| ShimmerDriver/src/test/java/com/shimmerresearch/driver/API_00022_SdHeaderPressureSensorIdTest.java | Tests header states, sensor IDs, and firmware gates. |
| ShimmerDriver/src/main/java/com/shimmerresearch/sensors/bmpX80/SdHeaderPressureSensorId.java | Decodes the pressure-sensor header byte. |
| ShimmerDriver/src/main/java/com/shimmerresearch/driver/ShimmerObject.java | Integrates header-based selection, calibration gating, logging, and state reset. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…alibrated Review fixes (Copilot, #313): - SdHeaderPressureSensorId is now Serializable. ShimmerObject holds one in a non-transient field once setPressureSensorIdFromSdHeader() has run, even for an absent header, and ShimmerPC.deepClone() serialises the device: it hit NotSerializableException and returned null. - When the SD header names a sensor the parser cannot calibrate, or none fitted, the calibrated pressure and temperature entries are now NaN rather than the array's default 0. The multimap already read NaN, having no CAL entry, but the arrays data structure and the parallel mCalData exposed 0 kPa and 0 degC as if they were readings. API_00022 round-trips each state through serialisation. The new API_00023 (ShimmerDriverPC) deep-clones a device for every header state, and runs buildMsg in both data structures: NaN for an unknown or not-fitted sensor, real values for a known one. Both fail without the fix. Co-Authored-By: Claude Opus 5.5 <[email protected]>
MAzalya
changed the base branch from
DEV-1110_bmp581_inband_sensor_id
to
master
October 5, 2026 03:15
MAzalya
approved these changes
Oct 5, 2026
MAzalya
left a comment
Contributor
There was a problem hiding this comment.
ok tested, all looks good
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Driver half of the Java parser change for DEV-1123.
Stacked on #311 (DEV-1110), so its base is that branch, and it builds on DEV-1110's in-band sensor-ID override. Once #311 merges, GitHub retargets this PR to
master. The SD parser that calls it is in ShimmerResearch/Shimmer-Advance-API#490. Firmware: ShimmerResearch/log-and-stream-common#142.The byte
LogAndStream now records the detected pressure part at SD header offset 224:
0xFE: no sensor fitted.0xFF: not recorded, i.e. older firmware.Changes
sensors/bmpX80/SdHeaderPressureSensorId: a small pure helper.parse(svo, byte)returns ABSENT, KNOWN, UNKNOWN or NOT_FITTED, plus the sensor ID and the inferred flag.isSupported(svo)is the gate: LogAndStream, plus either Shimmer3R ≥ v1.01.018 or Shimmer3 ≥ v1.01.006.ShimmerObject:setPressureSensorIdFromSdHeader(int). The ID is cleared with the board details, like DEV-1110's in-band ID.isSupportedBmp581()honours the header ID after the in-band ID, andisSupportedBmp280()gains the equivalent override on Shimmer3.isSupportedBmp280(). Without a header ID that's the same as before, because it delegates to the same IMU-generation rule.0xFE,buildMsgskips pressure calibration viaisPressureSensorCalibratable(), so the multimap gets only UNCAL. The calibrated arrays (the arrays data structure and the parallelmCalData) get NaN, not 0. There is no SR-rule fallback.consolePrintLn; inferred and unknown go toconsolePrintErrLn.isPressureSensorInferred()andgetPressureSensorIdSdHeader().SdHeaderPressureSensorIdisSerializable, becauseShimmerObjectholds one andShimmerPC.deepClone()serialises the device.Found along the way (not changed here)
ShimmerVerObject.compareVersions(svo, hardwareVersion, …)ignores its hardware argument (ShimmerVerObject.java:695-697). So the gate goes toUtilShimmer.compareVersionsdirectly, which does check the hardware. Fixed separately in #314 (merged).Testing
API_00022_SdHeaderPressureSensorIdTest(10 tests): decoding, the inferred bit, unknown and none, wrong-platform IDs, serialisation, and a hardware-aware gate. The gate test checks that a Shimmer3R at v1.1.6–1.1.17 does not pass and a Shimmer3 at 1.1.18 does.API_00023_SdHeaderPressureSensorIdShimmerPCTest(ShimmerDriverPC, 3 tests):deepClone()for every header state, andbuildMsgin both data structures: NaN for an unknown or not-fitted sensor, real values for a known one.cd ShimmerDriver && ./gradlew test: 123 tests, 0 failures.cd ShimmerDriverPC && ./gradlew build(the CI command, through theShimmer-Java-Android-API-named junction): 32ShimmerDriverPCtests, 0 failures.ShimmerDriverAdvancedtests against this branch: 19 tests, 0 failures.🤖 Generated with Claude Code